<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //100以内奇数和
    let i = 1;
    let sum = 0;
    do {
        sum += i;
        i += 2;
    } while (i < 100);
    console.log('100以内奇数和为：' + sum);


    //求100以内所有3的倍数的和
    let j = 1;
    let sum1 = 0;
    do {
        if (j % 3 == 0) {
            sum1 += j;
        }
        j++;
    } while (j < 100);
    console.log('100以内所有3的倍数的和为：', sum1);

    // 使用do-while循环：输出询问“我爱你，嫁给我吧？”，选择“你喜欢我吗？(y/n):"，如果输入为y则打印”我们形影不离“，若输入为n,则继续询问
    let answer;
    console.log('我爱你，嫁给我吧？');
    do {
        answer = prompt('你喜欢我吗？(y/n):');
        console.log(answer);
    } while (answer != 'y');
    if (answer == 'y') {
        console.log('我们形影不离');
    }
</script>

</html>